<?php
require_once substr(dirname(__FILE__),0,-1).'sub/init.php';
if(!in_array('trend',$navarr))exit('该功能已关闭');
if(!is_mobile())header("Location: ".Href('trend'));
$currfields="sex,grade,nickname,photo_s,photo_f";
$chk_u_jumpurl=mHref('trend');
require_once ZEAI.'m/my_chk_u.php';
require_once ZEAI.'m/div_left_so.php';
require_once ZEAI.'cache/udata.php';
require_once ZEAI.'cache/config_up.php';
require_once ZEAI.'sub/zeai_up_func.php';
require_once ZEAI.'cache/config_vip.php';
$switch        = json_decode($_ZEAI['switch'],true);
$trend_addflag = json_decode($_VIP['trend_addflag'],true);
$trend_bbsflag = json_decode($_VIP['trend_bbsflag'],true);
//
$data_sex=$row['sex'];
$data_grade=$row['grade'];
$data_photo_s=$row['photo_s'];
$data_photo_f=$row['photo_f'];
$data_nickname=dataIO($row['nickname'],'out');
$data_nickname = (empty($data_nickname))?'uid:'.$cook_uid:$data_nickname;
if($submitok == 'trend_bbs_add'){
	if(!ifint($fid))json_exit(array('flag'=>0,'msg'=>'zeai_fid_error'));
	if (empty($content) || str_len($content)>1000)json_exit(array('flag'=>0,'msg'=>'请输入内容(200字以内)'));
	if ($cook_content == $content && !empty($content))json_exit(array('flag'=>0,'msg'=>'请不要重复发表'));
	$T = $db->ROW(__TBL_TREND__,"uid,content","id=".$fid,"num");
	if ($T){
		$uid = $T[0];$Tcontent = trimhtml($T[1]);
		//
		$content = dataIO($content,'in',1000);
		$addtime    = date_str(ADDTIME-10);
		$photo_s_url= (!empty($data_photo_s) && $data_photo_f==1)?UP.$data_photo_s:RES.'photo_s'.$data_sex.'.png';
		$flag       = intval($trend_bbsflag[$data_grade]);
		$flag_str   = ($flag==0)?'，请等待我们审核':'';
		$db->query("INSERT INTO ".__TBL_TREND_BBS__." (uid,fid,content,addtime,flag) VALUES ($cook_uid,$fid,'$content',".ADDTIME.",$flag)");
		setcookie("cook_content",$content,time()+60,"/",$_ZEAI['CookDomain']);
		$sexcolor = ($data_sex==2)?' class=\'Chong\'':' class=\'Clan\'';
		$CC .= '<li>';
		$CC .= '<a onClick=\'trend_uFn('.$cook_uid.')\'><img class=\'m\' src=\''.$photo_s_url.'\'><h5'.$sexcolor.'>'.$data_nickname.'：<font>'.$addtime.'</font></h5></a>';
		$CC .= '<span>'.trimContact($content).'</span>';
		$CC .= '</li>';
		//
		//通知
		$row = $db->ROW(__TBL_USER__,'openid,subscribe',"id=".$uid,"num");
		if($row){
			$openid = $row[0];$subscribe = $row[1];
			//站内消息
			$title='关于您的动态【'.$Tcontent.'】有新的评论';
			$C = $title.'　　<a href='.Href('trend',$uid).' class=aQING>进入查看</a>';
			$db->SendTip($uid,$title,dataIO($C,'in',1000),'sys');
			//微信通知
			if (!empty($openid) && $subscribe==1){
				//客服通知
				$C = urlencode(dataIO($title.'<br>→<a href="'.HOST.'/m/trend.php?submitok=my">【进入查看】</a>','wx'));
				$ret = @wx_kf_sent($openid,$C,'text');
				$ret = json_decode($ret);
				//模版通知
				if ($ret->errmsg != 'ok'){
					$first   = (!empty($first))?dataIO($first,'out'):'系统智能提醒！';
					$remark  = '';
					$keyword1  = $title;
					$keyword3  = urlencode($_ZEAI['siteName']);
					$url       = urlencode(HOST.'/?z=trend&submitok=my');
					@wx_mb_sent('mbbh=ZEAI_ADMIN_INFO&openid='.$openid.'&keyword1='.$keyword1.'&keyword3='.$keyword3.'&time='.ADDTIME.'&first='.$first.'&remark='.$remark.'&url='.$url);
				}
			}
		}
		//通知END		
		json_exit(array('flag'=>1,'msg'=>'发表成功'.$flag_str,'C'=>$CC));
	}else{
		json_exit(array('flag'=>0,'msg'=>'zeai_nodata_error'));
	}
}elseif($submitok=='ajax_vdetail'){
	if(!ifint($tid))json_exit(array('flag'=>0,'msg'=>'zeai_id_error'));
	$T = $db->ROW(__TBL_TREND__,"content","id=".$tid,"num");
	if ($T){
		$Tcontent = dataIO($T[0],'out');
		preg_match('/<img.+src=\"?(.+\.(jpg|gif|bmp|bnp|png))\"?.+>/i',$Tcontent,$match);
		$src=$match[1];
		$src=str_replace(UP,"",$src);
		$V = $db->ROW(__TBL_VIDEO__,"id","path_s='$src'","num");
		if($V)json_exit(array('flag'=>1,'vid'=>$V[0]));
	}
	json_exit(array('flag'=>0,'msg'=>'zeai_nodata_error'));
}
/***********************主体SQL入口***************************/
//门店
if(!empty($AGT)){
	$agentSQL2=" AND b.agentid=".$AGT['agentid'];
}
//门店结束
$nodatatips = "<div class='nodatatips'><i class='ico'>&#xe608;</i>暂时木有动态</div>";
$_ZEAI['pagesize']= 5;
$ZEAI_SQL = "a.kind=1 AND a.uid=b.id AND b.flag=1";
if ($submitok == 'my' && ifint($cook_uid)){
	$_ZEAI['pagesize']= 500;
	$ZEAI_SQL .= " AND a.uid=".$cook_uid;
}else{
	$ZEAI_SQL .= " AND a.flag=1 ".$agentSQL2;
}
//处理表单
$keyword = trimhtml(dataIO($keyword,'out'));
if (!empty($keyword)){
	if (ifint($keyword)){
		$ZEAI_SQL .= " AND b.id='$keyword' ";
	}else{
		$ZEAI_SQL .= " AND b.nickname LIKE '%".$keyword."%' ";
	}
}
$sex=trimhtml(dataIO($sex,'out'));if(!empty($sex))$ZEAI_SQL .= doinsql('b.sex',$sex);
$addtime=intval($addtime);
if(ifint($addtime)){
	$addtimeF=$addtime*86400;
	$ZEAI_SQL .= " AND (".ADDTIME." - a.addtime ) < $addtimeF";
}
$areaid=trimhtml(dataIO($areaid,'out'));$areaid=getareaSQL($areaid);if(!empty($areaid))$ZEAI_SQL .= " AND b.areaid LIKE '%".$areaid."%' ";
$age=trimhtml(dataIO($age,'out'));
if(!empty($age)){
	$agearr=explode(',',$age);
	if (count($agearr) >= 1 && is_array($agearr)){
		$SQL="";
		foreach ($agearr as $V) {
			$V=explode('-',$V);$V1=intval($V[0]);$V2=intval($V[1]);$SQL1="";$SQL2="";
			if(ifint($V1))$SQL1 = "  ( (YEAR(CURDATE())-YEAR(b.birthday)-(RIGHT(CURDATE(),5)<RIGHT(b.birthday,5))) >= '$V1' ) ";
			if(ifint($V2))$SQL2 = "  ( (YEAR(CURDATE())-YEAR(b.birthday)-(RIGHT(CURDATE(),5)<RIGHT(b.birthday,5))) <= '$V2' ) ";
			if(!empty($SQL1) && !empty($SQL2)){
				if(!empty($SQL))$SQL .= " OR ";
				$SQL .= "(".$SQL1." AND ".$SQL2.")";
			}
		}
		$ZEAI_SQL .= " AND (".$SQL.") ";
	}
}
$love=trimhtml(dataIO($love,'out'));if(!empty($love))$ZEAI_SQL .= doinsql('b.love',$love);
$edu=trimhtml(dataIO($edu,'out'));if(!empty($edu))$ZEAI_SQL .= doinsql('b.edu',$edu);
if($t=='hot')$hotSQL = " a.agreenum DESC,";
//参数
$par = "&sex=".$sex."&addtime=".$addtime."&areaid=".$areaid."&age=".$age."&love=".$love."&edu=".$edu."&areatitle=".$areatitle;
$cs  =" t=".$t."&keyword=".$keyword.$par;
//主语句
$ZEAI_SELECT = "SELECT a.id,a.uid,a.piclist,a.content,a.agreenum,a.agreelist,a.addtime,b.sex,b.grade,b.nickname,b.photo_s,b.photo_f,b.birthday,b.pay,b.heigh,b.edu,b.areatitle,b.photo_ifshow,b.flag AS uflag ".$hotSQL1." FROM ".__TBL_TREND__." a,".__TBL_USER__." b WHERE ".$ZEAI_SQL." ORDER BY ".$hotSQL."a.id DESC";

//统计个数
$rtt  = $db->query("SELECT COUNT(*) FROM ".__TBL_TREND__." a,".__TBL_USER__." b WHERE ".$ZEAI_SQL);$roww = $db->fetch_array($rtt);
$ZEAI_total=$roww[0];
$ZEAI_totalP = ceil($ZEAI_total/$_ZEAI['pagesize']);
/***********************主体SQL结束***************************/
if ($submitok == 'ajax_list'){
	exit(Zeai_ajax_list_fn($ZEAI_totalP,$p));
}elseif($submitok == 'addupdate'){
	$content = dataIO($content,'in',280);
	if (empty($content))json_exit(array('flag'=>0,'msg'=>'请输入内容～'));
	if ($cook_content == $content && !empty($content))json_exit(array('flag'=>0,'msg'=>'请不要重复发布～'));
	if (!empty($morelist)){
		 if (is_weixin()){
			$serverIds = $morelist;
			if (str_len($serverIds) > 15){
				$serverIds = explode(',',$serverIds);
				foreach ($serverIds as $value) {
					$url="https://api.weixin.qq.com/cgi-bin/media/get?access_token=".wx_get_access_token()."&media_id=".$value;
					$dbname = wx_get_up('trend',$url,$cook_uid.'_','SB');
					$_s     = setpath_s($dbname);
					$piclist[]=$_s;
				}
				$piclist = implode(",",$piclist);
			}else{
				json_exit(array('flag'=>0,'msg'=>'zeai_serverIds_down_error'));
			}
		 }else{
			$sARR = explode(',',$morelist);
			foreach ($sARR as $value) {
				$_s = str_replace($_ZEAI['up2'].'/','',$value);
				u_pic_reTmpDir_send($_s,'trend');
				u_pic_reTmpDir_send(smb($_s,'b'),'trend');
				$_s = str_replace('/tmp/','/trend/',$_s);
				$piclist[] = $_s;
			}
			$piclist = implode(",",$piclist);
		}
	}
	setcookie("cook_content",$content,time()+20,"/",$_ZEAI['CookDomain']);
	$flag = intval($trend_addflag[$data_grade]);
	$db->query("INSERT INTO ".__TBL_TREND__." (uid,piclist,content,addtime,flag) VALUES ($cook_uid,'$piclist','$content',".ADDTIME.",$flag)");
	$flag_str= ($flag==0)?'，请等待我们审核':'';
	json_exit(array('flag'=>1,'msg'=>'发布成功'.$flag_str));
}elseif($submitok == 'delmy'){
	if(!ifint($id))exit(JSON_ERROR);
	$row = $db->ROW(__TBL_TREND__,"piclist","uid=".$cook_uid." AND id=".$id);
	if ($row){
		$piclist= $row[0];
		if(!empty($piclist)){
			$sARR = explode(',',$piclist);
			if(count($sARR) >0){
				foreach ($sARR as $value) {
					@up_send_userdel($value.'|'.smb($value,'b'));
				}
			}
		}
		$db->query("DELETE FROM ".__TBL_TREND__." WHERE kind=1 AND id=".$id." AND uid=".$cook_uid);
		$db->query("DELETE FROM ".__TBL_TREND_BBS__." WHERE kind=1 AND fid=".$id);
	}
	json_exit(array('flag'=>1,'msg'=>'删除成功'));
}elseif($submitok == 'ajax_photo_up_h5'){
	if (ifpostpic($file['tmp_name'])){
		$dbname = setphotodbname('tmp',$file['tmp_name'],$cook_uid.'_');
		if (!up_send($file,$dbname,$_UP['ifwaterimg'],$_UP['upMsize'],$_UP['upBsize']))json_exit(array('flag'=>0,'msg'=>'图片写入失败'));
		$_s = setpath_s($dbname);
		$tmppicurl = UP.$_s;
		json_exit(array('flag'=>1,'msg'=>'上传成功','_s'=>$_s));
	}else{
		json_exit(array('flag'=>0,'msg'=>'zeai_tmp_name_error'));
	}
}elseif($submitok == 'ajax_photo_up_app'){
	$f=$_FILES['file'];
	$dbname = setphotodbname('tmp',$file['tmp_name'],$cook_uid.'_');
	if (!up_send($f,$dbname,$_UP['ifwaterimg'],$_UP['upMsize'],$_UP['upBsize']))json_exit(array('flag'=>0,'msg'=>'图片写入失败'));
	$_s = setpath_s($dbname);
	$tmppicurl = UP.$_s;
	if (!ifpic($tmppicurl))json_exit(array('flag'=>0,'msg'=>'图片格式错误'));
	json_exit(array('flag'=>1,'msg'=>'上传成功','_s'=>$_s));

}elseif($submitok == 'ajax_agree'){
	if(!ifint($tid))json_exit(array('flag'=>0,'msg'=>'zeai_tid_error'));
	$T = $db->ROW(__TBL_TREND__,"uid,agreelist,content","id=".$tid,"num");
	if ($T){
		$uid = $T[0];$agreelist = $T[1];$content = trimhtml($T[2]);
		$newlist   = array($cook_uid);
		if (!empty($agreelist)){
			$agreelist = explode(',',$agreelist);
			if (in_array($cook_uid,$agreelist)){
				exit(json_encode(array('flag'=>0,'msg'=>'不能重复点赞哦～')));
			}else{
				$newlist = array_merge($newlist,$agreelist);
			}
		}
		$arrnum = count($newlist);
		$newlist = implode(',',$newlist);
		$db->query("UPDATE ".__TBL_TREND__." SET agreelist='$newlist',agreenum = agreenum+1 WHERE id=".$tid);
		//
		$imgurl    = (!empty($data_photo_s) && $data_photo_f==1)?UP.$data_photo_s:RES.'photo_m'.$data_sex.'.png';
		$classname = (empty($data_photo_s) || $data_photo_f==0)?'sexbg'.$data_sex:'';
		
		//通知
		$row = $db->ROW(__TBL_USER__,'openid,subscribe',"id=".$uid,"num");
		if($row){
			$openid = $row[0];$subscribe = $row[1];
			//站内消息
			$title='关于您的动态【'.$content.'】有人点赞了';
			$C = $title.'　　<a href='.Href('trend',$uid).' class=aQING>进入查看</a>';
			$db->SendTip($uid,$title,dataIO($C,'in',1000),'sys');
			//微信通知
			if (!empty($openid) && $subscribe==1){
				//客服通知
				$C = urlencode(dataIO($title.'<br>→<a href="'.HOST.'/m/trend.php?submitok=my">【进入查看】</a>','wx'));
				$ret = @wx_kf_sent($openid,$C,'text');
				$ret = json_decode($ret);
				//模版通知
				if ($ret->errmsg != 'ok'){
					$first   = (!empty($first))?dataIO($first,'out'):'系统智能提醒！';
					$remark  = '';
					$keyword1  = $title;
					$keyword3  = urlencode($_ZEAI['siteName']);
					$url       = urlencode(HOST.'/m/trend.php?submitok=my');
					@wx_mb_sent('mbbh=ZEAI_ADMIN_INFO&openid='.$openid.'&keyword1='.$keyword1.'&keyword3='.$keyword3.'&time='.ADDTIME.'&first='.$first.'&remark='.$remark.'&url='.$url);
				}
			}
		}
		//通知END
		
		exit(json_encode(array('flag'=>'1','num'=>$arrnum,'uid'=>$cook_uid,'classname'=>$classname,'imgurl'=>$imgurl)));
	}else{
		json_exit(array('flag'=>0,'msg'=>'zeai_nodata_error'));
	}
}
$nav='trend';
$headertitle = '会员动态 - ';
/***********************列表开始***************************/
?>
<!doctype html><html><head><meta charset="utf-8">
<title><?php echo $headertitle;?><?php echo $_ZEAI['siteName'];?></title>
<?php echo HEADMETA; ?>
<link href="<?php echo RES;?>m/css/m.css?<?php echo $_ZEAI['cache_str'];?>" rel="stylesheet" type="text/css" />
<link href="<?php echo HOST;?>/cache/zeaicolor.css?<?php echo $_ZEAI['cache_str'];?>" rel="stylesheet" type="text/css" />
<link href="<?php echo RES;?>m/css/trend.css?<?php echo $_ZEAI['cache_str'];?>" rel="stylesheet" type="text/css" />
<script src="<?php echo RES;?>www_zeai_cn.js?<?php echo $_ZEAI['cache_str'];?>"></script>
<script src="<?php echo RES;?>m/js/m.js?<?php echo $_ZEAI['cache_str'];?>"></script>
<script src="<?php echo HOST;?>/cache/areadata.js?<?php echo $_ZEAI['cache_str'];?>"></script>
<script src="<?php echo RES;?>m/js/zeai_div_area.js?<?php echo $_ZEAI['cache_str'];?>"></script>
<?php
if (is_weixin()){
	require_once ZEAI."api/weixin/jssdk.php";?>
	<script src="<?php echo RES;?>jweixin-1.2.0.js"></script>
	<script>
	wx.config({debug:false,
		appId: '<?php echo $signPackage["appId"];?>',
		timestamp: <?php echo $signPackage["timestamp"];?>,
		nonceStr: '<?php echo $signPackage["nonceStr"];?>',
		signature: '<?php echo $signPackage["signature"];?>',
		jsApiList: ['chooseImage','uploadImage','previewImage','hideMenuItems','onMenuShareTimeline','onMenuShareAppMessage','onMenuShareQQ','onMenuShareWeibo']
	});
	var share_title = '动态 - <?php echo dataIO($_ZEAI['siteName'],'out'); ?>',
	share_desc  = '我在这个网站发布了朋友圈动态，来看看啊^_^',
	share_link  = '<?php echo HOST; ?>/?z=trend',
	share_imgUrl= '<?php echo UP.$_ZEAI['logo']; ?>';
	wx.ready(function () {
		wx.onMenuShareAppMessage({title:share_title,desc:share_desc,link:share_link,imgUrl:share_imgUrl});
		wx.onMenuShareTimeline({title:share_title,link:share_link,imgUrl:share_imgUrl});
	});
	</script>
<?php }?>
<style>
.HONG{background-color:<?php echo $_ZEAI['mob_mbcolor'];?>}
#backtop a{background:#fff;color:<?php echo $_ZEAI['mob_mbcolor'];?>}
.trendmain dl .agree i.ed font,.trendmain dl .agree i:hover{color:<?php echo $_ZEAI['mob_mbcolor'];?>}
.trendmain dl dd span.ed:first-child,.trendmain dl dd span.chat{background-color:rgba(<?php echo c16_rgb($_ZEAI['mob_mbcolor']);?>,.08);color:<?php echo $_ZEAI['mob_mbcolor'];?>;border-color:rgba(<?php echo c16_rgb($_ZEAI['mob_mbcolor']);?>,.2)}
.trendmain dl dt span.ed{background-color:#fff}
.trend_add{box-shadow:0 .3rem .8rem rgba(<?php echo c16_rgb($_ZEAI['mob_mbcolor']);?>,.4);background-image:-webkit-linear-gradient(top,<?php echo $_ZEAI['mob_mbcolor'];?>,rgba(<?php echo c16_rgb($_ZEAI['mob_mbcolor']);?>,.8));}
#trendbox ul li b{background-image:url('<?php echo RES;?>picadd.png');background-size:12rem 8rem;background-repeat:no-repeat}
/*div_left_so*/
.div_left_so a.ed,
.div_left_so a.ed:after{color:<?php echo $_ZEAI['mob_mbcolor'];?>}
.div_left_so ul.def li.ed{color:<?php echo $_ZEAI['mob_mbcolor'];?>;background-color:rgba(<?php echo c16_rgb($_ZEAI['mob_mbcolor']);?>,.1)}
.div_left_so .listbox dl dd span.ed{color:<?php echo $_ZEAI['mob_mbcolor'];?>;border-top-color:<?php echo $_ZEAI['mob_mbcolor'];?>}
.div_left_so_areabox .ul dt.ed{color:<?php echo $_ZEAI['mob_mbcolor'];?>;border-top-color:<?php echo $_ZEAI['mob_mbcolor'];?>}
.div_left_so_areabox .ul li a.ed{color:<?php echo $_ZEAI['mob_mbcolor'];?>;background-color:rgba(<?php echo c16_rgb($_ZEAI['mob_mbcolor']);?>,.1)}
em.so{position:absolute;right:1.5rem;top:0;text-align:center;line-height:5rem;color:#fff;z-index:3}
em.so i{line-height:3rem;height:3rem;font-size:2.8rem;display:block;margin-top:.5rem}
em.so span{line-height:2rem;height:2rem;display:block;font-size:1.2rem;margin-top:-.8rem}
a.aQING{color:<?php echo $_ZEAI['mob_mbcolor'];?>}
/*topnav*/
.topnav1{background-image:url("<?php echo RES;?>m/img/my_bg.png");background-color:<?php echo $_ZEAI['mob_mbcolor'];?>}
.topnav a.ed:after{background-color:<?php echo $_ZEAI['mob_mbcolor'];?>}
.topnav1 a.ed:after{background-color:#fff}
</style></head><body>
<?php if ($submitok == 'add'){
	$mini_class='top_mini4 zeaibg bgcolor';
	$mini_L = '<em onClick="zeai.back()"><i class="ico" >&#xeaca;</i></em>';
	$mini_title = '发动态';
	$mini_R = '<a id="trend_btn_save">保存</a>';
    require_once ZEAI.'m/top_mini.php';
    ?>
	<script src="<?php echo RES;?>m/js/ZeaiUP.js?<?php echo $_ZEAI['cache_str'];?>"></script>
	<script src="<?php echo RES;?>m/js/trend.js?<?php echo $_ZEAI['cache_str'];?>"></script>
    <!--<a id="trend_btn_save">保存</a>-->
    <form id='trendbox'>
        <textarea name="content" id="content" placeholder="请输入内容，比如您这一刻的想法......"></textarea>
        <h4><span id="inpttext">0</span>/140</h4><ul><li> <i class="ico">&#xe609;</i><span>上传图片</span> </li></ul>
        <input type="hidden" name="morelist" id="morelist" value="">
    </form>
    <script>
        var ul = zeai.tag(o('trendbox'),"ul")[0],
        btnpic = ul.children[0],
        upMaxMB = <?php echo $_UP['upMaxMB']; ?>,
        browser='<?php if(is_h5app()){ echo 'app';}else{ echo (is_weixin())?'wx':'h5';}?>',
        up2='<?php echo UP;?>',trend_pic_Slist=[],localIds=[];
        trend_btn_save.onclick = trend_btn_saveFn;
        content.oninput = contentFn;
        btnpic.onclick = btnpicFn;
    </script> 
<?php exit;}?>
<?php if ($_ZEAI['m_mb']==2){$TRnav_btn = 'hide';$mainstyle=' style="margin-top:0"';require_once ZEAI.'m/top2.php';?>
	<div class="tab2">
        <a href="trend.php"><i class="_new ico">&#xe63b;</i><span>最新</span></a>
        <a href="trend.php?t=hot"><i class="_hot ico">&#xe643;</i><span>热门</span></a>
		<a href="trend.php?submitok=add"><i class="_add ico">&#xe622;</i><span>发布</span></a>
        <a href="trend.php?submitok=my"><i class="_my ico">&#xe63e;</i><span>我的</span></a>
        <a id="trend_search"><i class="_so ico">&#xe68c;</i><span>筛选</span></a>
    </div>
<?php }else{?>
    <div class="topnav<?php echo ($_ZEAI['m_mb']==1)?' topnav1':'';?>">
        <a href="trend.php"<?php echo (empty($submitok))?' class="ed"':'';?>>动态</a>
        <a href="trend.php?submitok=my"<?php echo ($submitok == 'my')?' class="ed"':'';?>>我的</a>
		<a href="trend.php?submitok=add">发布</a>
        <a id="trend_search"><i class="ico">&#xe68c;</i> 筛选</font></a>
    </div>
<?php }?>
<div class="trendmain" id="ZEAI_list"<?php echo $mainstyle;?>><?php if($ZEAI_totalP>0){echo Zeai_ajax_list_fn($ZEAI_totalP,$p);}else{echo $nodatatips;}?></div>
<?php if ($ZEAI_total > $_ZEAI['pagesize']){?>
<script>
var ZEAI_totalP = parseInt(<?php echo $ZEAI_totalP; ?>),p=2;
var scs='<?php echo trimhtml($cs); ?>';
var postjson = {submitok:'ajax_list',ZEAI_totalP:ZEAI_totalP};
if(!zeai.empty(scs))Object.assign(postjson,tojson(scs.split('&')));
zeaiOnscroll_json={url:MHOST+'/trend'+zeai.extname,data:postjson};
document.body.onscroll = function(){zeaiOnscroll({<?php if ($_ZEAI['m_mb']==2)echo 'doing:function(tt){trend_addFn(tt);},';?>end:function(){trendSetList();}});};
</script>
<div id="backtop"><a href="#top" id="btmTopBtn"><i class="ico">&#xe60c;</i>顶部</a></div>
<?php }?>
<a class="trend_add" href="trend.php?submitok=add" id="trend_add"<?php echo ($_ZEAI['m_mb']==2)?' style="display:none"':'';?>><i class="ico">&#xe609;</i> 发布</a>
<!--div_left_so-->
<div class="div_left_so" id="trend_so">
	<form action="<?php echo SELF;?>/m/trend.php" class="form_uid" name="www.zeai.cn">
        <input name="keyword" type="text" class="input" id="keyword" maxlength="20" value="<?php echo $keyword;?>" placeholder="按用户ID/昵称" autocomplete="off">
        <button type="submit" class="ico">&#xe6c4;</button>
	</form>
    <form action="<?php echo HOST;?>/m/trend.php" method="get" name="www.yzlove.com">
    <?php
	div_left_so_out(array('tbody'=>'性别','t'=>'sex','tv'=>$sex,'subkind'=>3,'newarr'=>json_decode($_UDATA['sex']),'ulcls'=>' col3'));
	div_left_so_out(array('tbody'=>'年龄','t'=>'age','tv'=>$age,'subkind'=>3,'newarr'=>json_decode('[{"i":"18-22","v":"18-22岁"},{"i":"23-25","v":"23-25岁"},{"i":"26-30","v":"26-30岁"},{"i":"31-35","v":"31-35岁"},{"i":"36-40","v":"36-40岁"},{"i":"41-45","v":"41-45岁"},{"i":"51-60","v":"51-60岁"},{"i":"61-120","v":"60岁以上"}]'),'ulcls'=>' col3'));
	div_left_so_out(array('tbody'=>'婚况','t'=>'love','tv'=>$love,'subkind'=>3,'newarr'=>json_decode($_UDATA['love']),'ulcls'=>' col3'));
	div_left_so_out(array('tbody'=>'学历','t'=>'edu','tv'=>$edu,'subkind'=>3,'newarr'=>json_decode($_UDATA['edu']),'ulcls'=>' col3'));
	div_left_so_out(array('tbody'=>'发布时间','t'=>'addtime','tv'=>$addtime,'subkind'=>2,'newarr'=>json_decode('[{"i":"3","v":"3天内"},{"i":"7","v":"1周内"},{"i":"30","v":"1月内"}]'),'ulcls'=>' col3'));
	?>
    <!--地区-->
    <div id="areabox" class="areabox div_left_so_areabox"><div class="ul"><li><dl><dd></dd></dl></li></div></div>
    <input type="hidden" id="form_areaid" name="areaid" value="<?php echo $areaid;?>">
    <input type="hidden" id="form_areatitle" name="areatitle" value="<?php echo $areatitle;?>">
    <div class="listbox"><dl id="areaid" data="<?php echo $areaid;?>"><dt>所在地区</dt><dd><span id="areatitle"><?php echo $areatitle;?></span></dd></dl></div>
	<script>
	o('areaid').onclick=function(){
		ZeaiM.div_up({obj:areabox,h:36});
		ZEAI_area({areaid:o('form_areaid').value,areatitle:o('form_areatitle').value,ul:areabox.children[0],bx:true,str:'job',end:function(z,e){
			o('areatitle').html(e);o('areatitle').class('ed');
			o('form_areaid').value=z;
			o('form_areatitle').value=e;
		}});
	}
    </script>
    <div class="savebox"><button type="button" class="btn size3 reset" id="div_left_so_resetbtn" onClick="div_left_so_reset('trend_so')">重置</button><button type="submit" class="btn size3 zeaibg ico">&#xe6c4; 确定</button></div>
    </form>
</div>
<!--div_left_so end-->
<script src="<?php echo RES;?>m/js/trend.js?<?php echo $_ZEAI['cache_str'];?>"></script>
<script>
var browser='<?php echo browser();?>';
trendSetList();
trend_search.onclick=trend_search_btnFn;
</script>
<?php if (is_weixin() && ($data_subscribe!=1)){wx_endurl('您刚刚浏览的页面【动态】',mHref('trend'));}
if($_ZEAI['m_mb']==2){
	echo "<script>setTimeout(function(){hdnavLRmoveFn(hdnav,60,'r');},100);</script>";
	require_once ZEAI.'m/bottom2.php';
}else{
	require_once ZEAI.'m/bottom.php';
}
require_once ZEAI.'m/TRnav.php';
function rows_ulist($rows) {
	global $_ZEAI,$db,$cook_uid;
	$id            = $rows['id'];
	$uid           = $rows['uid'];
	$piclist       = $rows['piclist'];
	$content       = dataIO($rows['content'],'out');
	$agreenum      = $rows['agreenum'];
	$agreelist     = $rows['agreelist'];
	$addtime_str   = date_str($rows['addtime']);
	$areatitle     = $rows['areatitle'];
	$area_s_title = explode(' ',$areatitle);$area_s_title = $area_s_title[1];
	//
	$sex           = $rows['sex'];
	$grade         = $rows['grade'];
	$nickname      = dataIO($rows['nickname'],'out');
	$nickname      = (empty($nickname))?'uid:'.$uid:$nickname;
	$photo_s       = $rows['photo_s'];
	$photo_f       = $rows['photo_f'];
	$photo_ifshow  = $rows['photo_ifshow'];
	$uflag  = $rows['uflag'];
	$birthday      = $rows['birthday'];
	$pay           = $rows['pay'];
	$heigh         = $rows['heigh'];
	$edu           = $rows['edu'];
	//
	$photo_s_url=photo_s_out('{"smb":"s","sex":"'.$sex.'","photo_s":"'.$photo_s.'","photo_f":"'.$photo_f.'","photo_ifshow":"'.$photo_ifshow.'","uflag":"'.$uflag.'","outkind":"url"}');	
	$ifh3 = ($birthday == '0000-00-00' && empty($heigh) && empty($pay) && empty($edu))?false:true;
	if ($ifh3){
		$unifo='';
		$unifo .= (empty($area_s_title))?'':'<b>・</b>'.$area_s_title;
		$unifo .= (getage($birthday)<=0)?'':'<b>・</b>'.getage($birthday).'岁';
		$unifo .= (empty($heigh))?'':'<b>・</b>'.udata('heigh',$heigh);
		$unifo .= (empty($edu))?'':'<b>・</b>'.udata('edu',$edu);
		//$unifo .= (empty($pay))?'':'<b>・</b>'.udata('pay',$pay);
	}
	$unifo=ltrim($unifo,'<b>・</b>');
	$piclist_str = '';
	if (!empty($piclist)){
		$piclist = explode(',',$piclist);
		if (count($piclist) >= 1){foreach ($piclist as $value){$piclist_str .= '<img src="'.UP.$value.'">';}}
	}
	//关注
	$gzflag = ($db->COUNT(__TBL_GZ__,"flag=1 AND senduid=".$cook_uid." AND uid=".$uid))?1:0;
	if($gzflag==1){
		$gzcls=' ed';
		$gzstr='&#xe905; 喜欢';
	}else{
		$gzcls='';
		$gzstr='&#xe70f; 喜欢';
	}
	//
	$echo  ='<dl id="dl'.$id.'">';
	$echo .='<dt uid="'.$uid.'"><a href="'.mHref('u',$uid).'"><img src="'.$photo_s_url.'"'.$sexbg.'></a></dt>';
	$echo .='<dd><span class="ico'.$gzcls.'">'.$gzstr.'</span>';
	$echo .='<h2><font>'.$nickname.'</font>'.uicon($sex.$grade).'</h2>';
	if($cook_uid!=$uid && @in_array('chat',$navarr))$echo .='<span class="ico chat">&#xe629; 聊天</span>';
	if ($cook_uid == $uid)$echo .='<a clsid="'.$id.'" class="delmy">删除</a>';
	if ($ifh3)$echo .='<h3>'.$unifo.'</h3>';
	//
	if(strstr($content,"photo_v")){
		preg_match('/<img.+src=\"?(.+\.(jpg))\"?.+>/i',$content,$match);
		$src = $match[1];
		$mp4 = str_replace('.jpg','.mp4',$src);
		$cvs = '<video class="zeaiVbox" id="zeaiVbox'.$id.'"><source src="'.$mp4.'">您浏览器本太低，请升级</video><span class="play ico">&#xe603;</span>';
		if(is_h5app()){ 		
			$vplay   = 'javascript:app_VideoPlayer("'.$mp4.'");';
		}else{
			$vplay   = 'zeaiplay("'.$id.'")';
		}
		$content = '<h1>上传了个人视频</h1><span class="vbox"><strong onclick='.$vplay.'><img src="'.$src.'">'.$cvs.'</strong></span>';
		$echo   .=$content;
	}else{
		$echo .='<h1>'.$content.'</h1>';
	}
	//
	if (!empty($piclist) && count($piclist) > 1){$echo .='<p>'.$piclist_str.'</p>';}else{$echo .='<h1>'.smb($piclist_str,'b').'</h1>';}
	$agreebbs='';
	//bbs
	$rt=$db->query("SELECT a.flag,a.uid,a.content,a.addtime,U.photo_s,U.photo_f,U.uname,U.nickname,U.sex,U.photo_ifshow,U.flag AS uflag FROM ".__TBL_TREND_BBS__." a,".__TBL_USER__." U WHERE a.uid=U.id AND U.flag=1 AND a.fid=$id ORDER BY a.id DESC");
	$C = '';$k=0;
	WHILE ($rowsbbs = $db->fetch_array($rt,'name')){
		$k++;
		$flag     = $rowsbbs['flag'];
		$uid      = $rowsbbs['uid'];
		$sex      = $rowsbbs['sex'];
		$photo_s  = $rowsbbs['photo_s'];
		$photo_f  = $rowsbbs['photo_f'];
		$photo_ifshow = $rowsbbs['photo_ifshow'];
		$uflag    = $rowsbbs['uflag'];
		$uname    = dataIO($rowsbbs['uname'],'out');
		$nickname = dataIO($rowsbbs['nickname'],'out');
		$nickname = (empty($nickname))?$uname:$nickname;
		$nickname = (ifmob($nickname))?$uid:$nickname;
		$content  = trimhtml(dataIO($rowsbbs['content'],'out'));
		$content  = ($flag==1)?$content:'<font class="C999">审核中</font>';
		$photo_s_url=photo_s_out('{"smb":"s","sex":"'.$sex.'","photo_s":"'.$photo_s.'","photo_f":"'.$photo_f.'","photo_ifshow":"'.$photo_ifshow.'","uflag":"'.$uflag.'","outkind":"url"}');	
		$addtime  = date_str($rowsbbs['addtime']);
		//$sexcolor = ($sex==2)?' class="Chong"':' class="Clan"';
		$C .= '<li>';
		$C .= '<a onClick="trend_uFn('.$uid.')"><img class="m" src="'.$photo_s_url.'" uid="'.$uid.'"><h5'.$sexcolor.'>'.$nickname.'：<font>'.$addtime.'</font></h5></a>';
		$C .= '<span>'.trimContact($content).'</span>';
		$C .= '</li>';
	}
	//bbs end
	//agree
	if (!empty($agreelist)){
		$agreelistarr= explode(',',$agreelist);
		$agree_class = (in_array($cook_uid,$agreelistarr))?' class="ed"':'';
		$agree_ulist = '';
		foreach ($agreelistarr as $uid2){
			$AU = $db->ROW(__TBL_USER__,"sex,photo_s,photo_f,photo_ifshow,flag","id=".$uid2,"num");
			$sex2     = $AU[0];
			$photo_s2 = $AU[1];
			$photo_f2 = $AU[2];
			$photo_ifshow2 = $AU[3];
			$uflag2   = $AU[4];
			$photo_s2_url=photo_s_out('{"smb":"s","sex":"'.$sex2.'","photo_s":"'.$photo_s2.'","photo_f":"'.$photo_f2.'","photo_ifshow":"'.$photo_ifshow2.'","uflag":"'.$uflag2.'","outkind":"url"}');	
			$agree_ulist .= '<img src="'.$photo_s2_url.'" uid="'.$uid2.'">';
		}
	}else{
		$agree_class = '';
	}
	//$agreebbs ='<div class="agree" tid="'.$id.'"><span class="time">'.$addtime_str.'</span><i'.$agree_class.'><font class="ico">&#xe652;</font><font> 赞<b class="agreefly">+1</b><span>'.$agreenum.'</span>　</font></i><i><font class="ico S16">&#xe676;</font><font> 评<span>'.$k.'</span></font></i></div>';
	$agreebbs ='<div class="agree" tid="'.$id.'"><span class="time">'.$addtime_str.'</span><i'.$agree_class.'><font class="ico">&#xe652;</font><font> <b class="agreefly">+1</b><span>'.$agreenum.'</span>　</font></i><i><font class="ico S16">&#xe676;</font><font> <span>'.$k.'</span></font></i></div>';
	
	if ($agreenum>0 || $k>0){$agreebbs .='<div class="j"></div>';}
	if ($agreenum>0 && !empty($agreelist)){$agreebbs .='<em>'.$agree_ulist.'</em>';}
	if(!empty($C))$agreebbs .='<ul>'.$C.'</ul>';
	$echo .='</dd>';
	$echo .=$agreebbs;
	$echo .='</dl>';
	return $echo;
}
?>